//
//  TBRMineVipC.m
//  TBText
//
//  Created by yy on 2018/4/29.
//  Copyright © 2018年 yy. All rights reserved.
//

#import "TBRMineVipC.h"
//#import "TBRMineVipIconCell.h"
//#import "TBRMineVipDetailCell.h"

#import "TBRMineVipHeadView.h"
#import "TBRMineVipMemberRightCell.h"
#import "TBRMineVipRules.h"

#import "TBRMineModel.h"
#import <YYModel.h>
@interface TBRMineVipC ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic,strong)NSMutableArray *dataArray;
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic,strong)TBRMineVipHeadView *headView;
@end

@implementation TBRMineVipC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
    
    //加载数据
    [self loadData];
}

- (void)setupUI {
    //设置导航条
    [self setupNavItem];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.tableFooterView = [UIView new];
    
    TBRMineVipHeadView *headView = [TBRMineVipHeadView mineVipHeadView];
    headView.frame = CGRectMake(0, 0, Width, 125);
    self.headView = headView;
    self.tableView.tableHeaderView = headView;
    
    [self.tableView registerNib:[UINib nibWithNibName:@"TBRMineVipMemberRightCell" bundle:nil] forCellReuseIdentifier:@"TBRMineVipMemberRightCellId"];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"TBRMineVipRules" bundle:nil] forCellReuseIdentifier:@"TBRMineVipRulesId"];
}


- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    _headView.frame = CGRectMake(0, 0, Width, 125);
}

- (void)setupNavItem {
    self.titleText = @"我的会员";
}


#pragma mark - 返回组
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}

#pragma mark - 返回行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

#pragma mark - 返回每行内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    //自定义cell
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[self getIdentifier:indexPath] forIndexPath:indexPath];
    [self setupCell:cell indexPath:indexPath];
    return cell;
}

- (NSString *)getIdentifier:(NSIndexPath *)indexPath {
    NSString *iden = @"TBRMineVipMemberRightCellId";
    if (indexPath.section == 0) {
        iden = @"TBRMineVipMemberRightCellId";
    }else {
        iden = @"TBRMineVipRulesId";
    }
    return iden;
}

- (void)setupCell:(UITableViewCell *)cell indexPath:(NSIndexPath *)indexPath {
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if (indexPath.section == 0) {
        TBRMineVipMemberRightCell *cellVipMemberRight = (TBRMineVipMemberRightCell *)cell;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return indexPath.section == 0 ? 229 : 120;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Width, 10)];
    view.backgroundColor = [UIColor colorWithHex:0xe6e6e6];
    return view;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 10;
}

// MARK: - 加载数据
- (void)loadData {
    [self loadLocalData];
    [self loadNetData];
}
// MARK: - 本地数据
- (void)loadLocalData {
    self.dataArray = [NSMutableArray array];
    NSArray *tmpArray = @[
                          @[@{@"messageId":@"userName",@"imageName":@"",@"titleName":@"用户名",
                              @"detailName":@"丁晓龙"},@{@"messageId":@"userName",@"imageName":@"",@"titleName":@"用户名",@"detailName":@"丁晓龙"}],
                          @[@{@"messageId":@"phoneNum",@"imageName":@"",@"titleName":@"手机",@"detailName":@"13373633086"}],
                          @[@{@"messageId":@"password",@"imageName":@"",@"titleName":@"登录密码",@"detailName":@"未设置"},
                            @{@"messageId":@"payType",@"imageName":@"",@"titleName":@"支付方式",@"detailName":@"我的客服"},]
                          ];
    
    for (NSArray *tmpEnumArray in tmpArray) {
        NSArray *tmpModelArray = [NSArray yy_modelArrayWithClass:[TBRMineInfoBasicModel class] json:tmpEnumArray];
        [self.dataArray addObject:tmpModelArray];
    }
    
}

// MARK: - 获取网络数据-----
- (void)loadNetData {
    
}
@end
